package com.qfedu.empproject.controller;

import com.qfedu.empproject.entity.Emp;
import com.qfedu.empproject.service.EmpService;
import com.qfedu.empproject.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ToEditEmp")
public class EditEmpController extends HttpServlet {
    private EmpService empService = new EmpServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //超连接请求进入doget方法 获取员工的ID
        String id = req.getParameter("id");
        Emp emp = empService.selectByld(id);
        //System.out.println(emp);
        //存用户信息到rep
        req.setAttribute("emp",emp);
        //服务器内部转发到编辑员工的页面
        req.getRequestDispatcher("/manager/editEmp.jsp").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
